import java.awt.*;
import java.util.*;
import java.math.*; 
import java.awt.geom.*;
public class ModifyPolygon extends java.awt.Polygon {
	int id;
	int ts; 
	Point p ; 
	java.awt.Polygon innerRing;  
	ArrayList <Line2D> listLines =new ArrayList <Line2D>();
	public ModifyPolygon(){ 
		super(); 
		innerRing = new java.awt.Polygon();
	}
	public void addPoint(Point p){ 
		addPoint((int)p.x,(int)p.y); 
	}
	
	public void addInnerPoint(Point p){ 
		innerRing.addPoint((int)p.x,(int)p.y); 
	} 
	public boolean contains(Point p){
		/*Rectangle myBox = this.getBounds();
		if(!myBox.contains(p.x, p.y)) return false;	*/	
		if(innerRing.contains((int)p.x,(int)p.y)) return false;
		return contains(p.x,p.y);
	}
	public boolean within(Point p,int distance){  
		if(this.contains(p)== true) return true;
		//Rectangle r = new Rectangle();  
		double xr = (p.x - ((distance/2)*Math.sqrt(2)));
		double yr = (p.y - ((distance/2)*Math.sqrt(2)));
		
		double height = (Math.sqrt(2)* (distance)); 
		double width = height; 
		if( this.intersects(xr, yr, height, width)) return true;

		double minDist = Double.MAX_VALUE;
		for(int i = 0 ; i < this.npoints ; i++){
			double dist = java.awt.geom.Point2D.distance(p.x,p.y,this.xpoints[i],this.ypoints[i]);
			if( dist < minDist )minDist = dist; 
			if(minDist <= distance)break;
		}

		//System.out.println("Here");
		if(minDist <= distance) return true;
		else return false;
		
	}
	public void makeLines(){   // call this method after we input all the points 
		for(int i =0;i<this.npoints - 1;i++)
		{
			Line2D line = new Line2D.Double(); 
			line.setLine(this.xpoints[i],this.ypoints[i],this.xpoints[i+1],this.ypoints[i+1]); 
			listLines.add(line); 
		}
		
		
	} 
	public boolean onLine(Point p ){
		boolean within = false; 
		for(Line2D tempLine : listLines){
			if(tempLine.ptSegDist(p.x,p.y)== 0 )
			{
				within = true; 
				break; 
			}
		}
		return within; 
	}
	public static void main( String [] args)
	{/*
		ModifyPolygon mPoly = new ModifyPolygon(); 
		Point [] points = new Point[5]; 
		Point [] innerPoints = new Point[4]; 
		points[0] = new Point(0,0); 
		points[1] = new Point(0,6.3543);
		points[2] = new Point(6.23223,6.34);
		points[3] = new Point(6.232,0);
		points[4] = new Point(0,0); 
		for(int i = 0 ; i < points.length;i++)
		{
			mPoly.addPoint(points[i]);
		}
		innerPoints[0] = new Point(1,1); 
		innerPoints[1] = new Point(2,1);
		innerPoints[2] = new Point(1,2); 
		innerPoints[3] = new Point(1,1); 
		for(int i = 0 ; i < innerPoints.length;i++)
		{
			mPoly.addInnerPoint(innerPoints[i]);
		}
		Point [] testPoints = new Point[4];  
		testPoints[0] = new Point(1.2,1.2); //inside triangle
		testPoints[1] = new Point(0.5,0.5); 
		testPoints[2] = new Point(5.5,5.5); 
		testPoints[3] = new Point(7,7);  
		
		for(int i = 0 ; i < testPoints.length;i++)
		{
			System.out.println( "test point : " + testPoints[i].x + ", " + testPoints[i].y + "is in Polygon: " + mPoly.contains(testPoints[i]));
		} */
		//Point ptry = new Point(6.5,6.5); 
		System.out.println("Here");
		Rectangle r = new Rectangle(0,6,6,6);
		if(r.contains(5,7)) System.out.println("Mark");
		
		
	}
}
